﻿<%@ Page Title="" Language="C#" MasterPageFile="~/_console/_console.Master" AutoEventWireup="true" CodeBehind="user-add.aspx.cs" Inherits="SmartSpace.WebApp._console.core.user_add" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderHead" runat="server">
    <script type="text/javascript">
        function checkSpecialStr(str) {
            var bl = true;
            var arr = new Array("@", "#", "$", "%", "&", "|", "\\", "//");
            i = arr.length;
            j = str.length;
            str = $.trim(str);
            if (str == "") {
                bl = true;
            } else {
                for (ii = 0; ii < i; ii++) {
                    for (jj = 0; jj < j; jj++) {
                        temp1 = str.charAt(jj);
                        temp2 = arr[ii];
                        if (temp1 == temp2) {
                            bl = false;
                        }
                    }
                }
            }
            return bl;
        }

        function checkSubmit() {
            var msg = "";
            var str_Account = $("#_ctlEditAccount").val();
            var str_Name = $("#_ctlEditName").val();
            var str_Email = $("#_ctlEditEmail").val();
            var str_Phone = $("#_ctlEditPhone").val();
            var reg_Account = /^[0-9A-Za-z_]{6,15}$/;
            var reg_Name = /^[0-9a-zA-Z]{6,20}$/;
            var reg_Email = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
            var reg_Phone = /(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
            if ($.trim(str_Account).length == 0) {
                msg = "Account is not allow null!";
            }
            if ($.trim(str_Name).length == 0) {
                msg = "Name is not allow null!";
            }
            if ($.trim(str_Email).length == 0) {
                msg = "Email is not allow null!";
            }
            if ($.trim(str_Phone).length == 0) {
                msg = "Phone is not allow null!";
            }

            if ($.trim(str_Phone).length != 0 && !reg_Phone.exec(str_Phone)) {
                msg = "请输入11位手机号码!";
            }
            if ($.trim(str_Email).length != 0 && !reg_Email.test(str_Email)) {
                msg = "邮箱格式必须正确!";
            }
            if ($.trim(str_Name).length != 0 && !checkSpecialStr(str_Name)) {
                msg = "Name不允许为非法字符!";
            }
            if ($.trim(str_Account).length != 0 && !reg_Account.test(str_Account)) {
                msg = "用户名必须为下划线,字母,小数,长度为6-15!";
            }
            if (msg == "") {
                if (window.confirm("Are you sure to add this information?")) {
                    return true;
                }
                else {
                    return false;
                }
            }
            else {
                alert(msg);
                return false;
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderMenu" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderTitle" runat="server">
    添加新用户
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolderToolbar" runat="server">
    <asp:HyperLink ID="_ctlLinkBack" runat="server" NavigateUrl="~/_console/core/user-list.aspx">返回</asp:HyperLink>
    <asp:LinkButton ID="_ctlBtnSave" runat="server" Text="保存" OnClick="_ctlBtnSave_Click" OnClientClick="return checkSubmit();" />
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ContentPlaceHolderContent" runat="server">
    <div class="form">
        <label>
            Account</label><br />
        <asp:TextBox ID="_ctlEditAccount" runat="server" ClientIDMode="Static"></asp:TextBox><br />
        <label>
            Name</label><br />
        <asp:TextBox ID="_ctlEditName" runat="server" ClientIDMode="Static"></asp:TextBox><br />
        <label>
            Email</label><br />
        <asp:TextBox ID="_ctlEditEmail" runat="server" ClientIDMode="Static"></asp:TextBox><br />
        <label>
            Phone</label><br />
        <asp:TextBox ID="_ctlEditPhone" runat="server" ClientIDMode="Static"></asp:TextBox><br />
    </div>
</asp:Content>
